package cn.seecoder.ai.controller;

import cn.seecoder.ai.model.vo.FileInfoVO;
import cn.seecoder.ai.model.vo.ModelVO;
import cn.seecoder.ai.model.vo.ResultVO;
import cn.seecoder.ai.service.SquareService;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author DingXiaoyu
 * @date 2023/4/13 11:36
 */
@Slf4j
@RestController
@RequestMapping("${apiPrefix}/squares")
public class SquareController {

    @Autowired
    SquareService squareService;

    @ApiOperation("分享文件")
    @PostMapping("/shareFile")
    public ResultVO<Boolean> shareFile(@RequestParam(value = "userId") Integer userId,
                                       @RequestParam(value = "fileId") Integer fileId){
        return ResultVO.buildSuccess(squareService.shareFile(userId,fileId));
    }

    @ApiOperation("分享模型")
    @PostMapping("/shareModel")
    public ResultVO<Boolean> shareModel(@RequestParam(value = "userId") Integer userId,
                                       @RequestParam(value = "modelId") Integer modelId){
        return ResultVO.buildSuccess(squareService.shareModel(userId,modelId));
    }

    @ApiOperation("收藏文件")
    @PostMapping("/collectFile")
    public ResultVO<Boolean> collectFile(@RequestParam(value = "userId") Integer userId,
                                        @RequestParam(value = "fileId") Integer fileId){
        return ResultVO.buildSuccess(squareService.collectFile(userId,fileId));
    }

    @ApiOperation("分享模型")
    @PostMapping("/collectModel")
    public ResultVO<Boolean> collectModel(@RequestParam(value = "userId") Integer userId,
                                        @RequestParam(value = "modelId") Integer modelId){
        return ResultVO.buildSuccess(squareService.collectModel(userId,modelId));
    }

    @ApiOperation("获取共享文件列表")
    @GetMapping("/sharedFileList")
    public ResultVO<List<FileInfoVO>> sharedFileList(@RequestParam(value = "userId") Integer userId){
        return ResultVO.buildSuccess(squareService.sharedFileList(userId));
    }

    @ApiOperation("获取共享模型列表")
    @GetMapping("/sharedModelList")
    public ResultVO<List<ModelVO>> sharedModelList(@RequestParam(value = "userId") Integer userId){
        return ResultVO.buildSuccess(squareService.sharedModelList(userId));
    }

    @ApiOperation("获取收藏文件列表")
    @GetMapping("/collectFileList")
    public ResultVO<List<FileInfoVO>> collectFileList(@RequestParam(value = "userId") Integer userId){
        return ResultVO.buildSuccess(squareService.collectFileList(userId));
    }

    @ApiOperation("获取收藏模型列表")
    @GetMapping("/collectModelList")
    public ResultVO<List<ModelVO>> collectModelList(@RequestParam(value = "userId") Integer userId){
        return ResultVO.buildSuccess(squareService.collectModelList(userId));
    }
}
